package day18.zhiyou100;

public class MyThread extends Thread{

    public MyThread(){

    }
    public MyThread(String name) {
        super(name);
    }

    // 重写Thread类中的run方法
    @Override
    public void run() {
        for (int i = 0; i < 50; i++) {
            System.out.println(this.getName() + "---" + i);
        }
    }

}

// 定义一个测试类
class Test1 {
    public static void main(String[] args) {
        // 创建该类的对象
        MyThread t1 = new MyThread("t1");
        MyThread t2 = new MyThread("t2");
        MyThread t3 = new MyThread("t3");
        t1.start();
        t2.start();
        Object obj = new Object();
        try {
            obj.wait();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        t3.start();
        obj.notify();

        // 打印50个数字
        for (int i = 0; i < 50; i++) {
            System.out.println(Thread.currentThread().getName() +"------"+ i);
        }

    }

}